const Mock = require('mockjs')

const Random = Mock.Random
// mock.js 模拟数据 生产验证码
let Result = {
    code: 200,
    massage: "操作成功",
    data: null
}
//模拟请求后台 获取验证码
Mock.mock('/captcha', 'get', () => {
    Result.data = {
        token: Random.string(32),
        captchaImg: Random.dataImage('100x40', 'p7n5w')
    }
    return Result
})
//模拟请求后台 登录
Mock.mock('/login', 'post', () => {
    // mock 无法往 header 传入jwt
    Result.code = 200
    Result.massage = "操作成功"
    return Result
})
//模拟请求后台 获取用户信息
Mock.mock('/sys/userInfo', 'get', () => {
    Result.data = {
        id: "1",
        username: "udiUser",
        avatar: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg9.doubanio.com%2Fview%2Frichtext%2Flarge%2Fpublic%2Fp226014745.jpg&refer=http%3A%2F%2Fimg9.doubanio.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1645760081&t=0cec015c5a40c1b165935fa2c81a3571"
    }
    return Result
})
//模拟请求后台 退出系统
Mock.mock('/logout', 'post', () => {
    return Result
})
//模拟请求后台 获取菜单信息和用户操作权限
Mock.mock('/sys/menu/nav', 'get', () => {
    //菜单列表
    let nav = [
        { name: 'ComManagement',
            title: '公司管理',
            icon: 'el-icon-office-building',
            path: '',
            component: '',
            children: [
                {
                    name: 'ComInformation',
                    title: '公司信息管理',
                    path: '',
                    component: '',
                },
                {
                    name: 'zc',
                    title: '注册备案信息',
                    path: '/sys/zc',
                    component: '/sys/ZC',
                },
                {
                    name: 'ComList',
                    title: '公司列表',
                    path: '',
                    component: '',
                },
                {
                    name: 'ComRenewal',
                    title: '公司续费管理',
                    path: '',
                    component: '',
                }/*,
                {
                    name: 'SysMenu',
                    title: '菜单管理',
                    icon: 'el-icon-menu',
                    path: '/sys/menus',
                    component: 'sys/Menu',
                    children: []
                }*/
            ]
        },
        {
            name: 'UserRight',
            title: '用户及权限管理',
            icon: 'el-icon-s-tools',
            path: '',
            component: '',
            children: [
                {
                    name: 'ComUser',
                    title: '用户管理',
                    path: '/sys/user',
                    component: '/sys/User'
                },
                {
                    name: 'Role',
                    title: '角色管理',
                    path: '/sys/roles',
                    component: 'sys/Role',
                },
                {
                    name: 'ComJurisdiction',
                    title: '权限管理',
                    path: '',
                    component: '',
                }
            ]
        },
        {
            name: 'ComCoding',
            title: '编码配置与生成',
            icon: 'el-icon-s-tools',
            path: '',
            component: '',
            children: [
                {
                    name: 'ApplicationIdentifier',
                    title: '应用标识符',
                    path: '/encodingconfiguration/applid',
                    component: 'encodingconfiguration/ApplicationIdentifier',
                },
                {
                    name: 'ComProduction',
                    title: '产品标识管理',
                    path: '',
                    component: '',
                }
            ]
        },
        {
            name: 'ComSystem',
            title: '系统管理',
            icon: 'el-icon-s-tools',
            path: '',
            component: '',
            children: [
                {
                    name: 'ComConfiguration',
                    title: '接口配置',
                    icon: 'el-icon-s-order',
                    path: '',
                    component: '',
                },
                {
                    name: 'ComCall',
                    title: '接口调用日志',
                    icon: 'el-icon-s-order',
                    path: '',
                    component: '',
                }
            ]
        }
    ]
    let authoritys = []
    Result.data = {
        nav: nav,
        authoritys: authoritys
    }
    return Result
})
//////////////// 菜单管理 ////////////////

Mock.mock('/sys/menu/list', 'get', () => {
    let menus = [
        {
            "id": 1,
            "created": "2021-01-15T18:58:18",
            "updated": "2021-01-15T18:58:20",
            "status": 1,
            "parentId": 0,
            "name": "系统管理",
            "path": "",
            "perms": "sys:manage",
            "component": "",
            "type": 0,
            "icon": "el-icon-s-operation",
            "orderNum": 1,
            "children": [
                {
                    "id": 2,
                    "created": "2021-01-15T19:03:45",
                    "updated": "2021-01-15T19:03:48",
                    "status": 1,
                    "parentId": 1,
                    "name": "用户管理",
                    "path": "/sys/users",
                    "perms": "sys:user:list",
                    "component": "sys/User",
                    "type": 1,
                    "icon": "el-icon-s-custom",
                    "orderNum": 1,
                    "children": [
                        {
                            "id": 9,
                            "created": "2021-01-17T21:48:32",
                            "updated": null,
                            "status": 1,
                            "parentId": 2,
                            "name": "添加用户",
                            "path": null,
                            "perms": "sys:user:save",
                            "component": null,
                            "type": 2,
                            "icon": null,
                            "orderNum": 1,
                            "children": []
                        },
                        {
                            "id": 10,
                            "created": "2021-01-17T21:49:03",
                            "updated": "2021-01-17T21:53:04",
                            "status": 1,
                            "parentId": 2,
                            "name": "修改用户",
                            "path": null,
                            "perms": "sys:user:update",
                            "component": null,
                            "type": 2,
                            "icon": null,
                            "orderNum": 2,
                            "children": []
                        },
                        {
                            "id": 11,
                            "created": "2021-01-17T21:49:21",
                            "updated": null,
                            "status": 1,
                            "parentId": 2,
                            "name": "删除用户",
                            "path": null,
                            "perms": "sys:user:delete",
                            "component": null,
                            "type": 2,
                            "icon": null,
                            "orderNum": 3,
                            "children": []
                        },
                        {
                            "id": 12,
                            "created": "2021-01-17T21:49:58",
                            "updated": null,
                            "status": 1,
                            "parentId": 2,
                            "name": "分配角色",
                            "path": null,
                            "perms": "sys:user:role",
                            "component": null,
                            "type": 2,
                            "icon": null,
                            "orderNum": 4,
                            "children": []
                        },
                        {
                            "id": 13,
                            "created": "2021-01-17T21:50:36",
                            "updated": null,
                            "status": 1,
                            "parentId": 2,
                            "name": "重置密码",
                            "path": null,
                            "perms": "sys:user:repass",
                            "component": null,
                            "type": 2,
                            "icon": null,
                            "orderNum": 5,
                            "children": []
                        }
                    ]
                },
                {
                    "id": 3,
                    "created": "2021-01-15T19:03:45",
                    "updated": "2021-01-15T19:03:48",
                    "status": 1,
                    "parentId": 1,
                    "name": "角色管理",
                    "path": "/sys/roles",
                    "perms": "sys:role:list",
                    "component": "sys/Role",
                    "type": 1,
                    "icon": "el-icon-rank",
                    "orderNum": 2,
                    "children": []
                },

            ]
        },
        {
            "id": 5,
            "created": "2021-01-15T19:06:11",
            "updated": null,
            "status": 1,
            "parentId": 0,
            "name": "系统工具",
            "path": "",
            "perms": "sys:tools",
            "component": null,
            "type": 0,
            "icon": "el-icon-s-tools",
            "orderNum": 2,
            "children": [
                {
                    "id": 6,
                    "created": "2021-01-15T19:07:18",
                    "updated": "2021-01-18T16:32:13",
                    "status": 1,
                    "parentId": 5,
                    "name": "数字字典",
                    "path": "/sys/dicts",
                    "perms": "sys:dict:list",
                    "component": "sys/Dict",
                    "type": 1,
                    "icon": "el-icon-s-order",
                    "orderNum": 1,
                    "children": []
                }
            ]
        }
    ]

    Result.data = menus

    return Result
})

Mock.mock(RegExp('/sys/menu/info/*'), 'get', () => {

    Result.data = {
        "id": 3,
        "statu": 1,
        "parentId": 1,
        "name": "角色管理",
        "path": "/sys/roles",
        "perms": "sys:role:list",
        "component": "sys/Role",
        "type": 1,
        "icon": "el-icon-rank",
        "orderNum": 2,
        "children": []
    }

    return Result
})


Mock.mock(RegExp('/sys/menu/*'), 'post', () => {

    return Result
})
